#ifndef WORLDENTITY_H
#define WORLDENTITY_H

#include "Vector2i.h"
#include "Rectangle.h"

enum eSide
{
	eSidePlayer,
	eSideEnemy,
	eSideNeutral
};

//!Represent an entity in the world.
class CWorldEntity
{
protected:
	//!Graphic index
	int m_indexGfx;
	
	//!Position of the entity
	CVector2i m_position;

	//!Previous position of the entity
	CVector2i m_previousPosition;

	//!Flag to say if this entity can collide
	bool m_canCollide;
	
	//!Rectangle collision
	CRectangle m_rectangleCollision;

	//!Flag to say if the entity is active
	bool m_active;

	//!Flag to say the side of the entity
	eSide m_side;

	//!Health point of the entity
	int m_healthPoint;

	//!Damage point cause by the entity
	int m_damagePoint;

public:
	//!Constructor
	/*!
	\param indexGfx Graphic idnex of the entity
	\param position Initial position of the entity
	\param canCollide Set if the entity can collide with other entities.
	*/
	CWorldEntity(int indexGfx, const CVector2i& position, bool canCollide);

	//!Destructor
	virtual ~CWorldEntity();

	//!Update the entity
	virtual void doUpdate(void)=0;

	//!Render the entity.
	virtual void doRender(void)=0;

	//!Check if the entity is colliding with otherEntity.
	/*!
	\param otherEntity The entity to test the collision with
	\return True if there is a collision.Return false is there is no collision.
	*/
	bool isCollidingWith(CWorldEntity* otherEntity);

	//!Collision rectangle gettor.
	/*!
	\return The collision rectangle. 
	*/
	CRectangle getCollisionRectangle(void)const;

	//!Get the flag indicating if the entity colide.
	/*!
	\return A boolean to true if the entity detects collision. It returns false if it doesn't.
	*/
	bool getCanCollide(void)const;

	//!Return the position of the entity
	/*!
	\return Return the position of the entity.
	*/
	CVector2i getPosition(void)const;

	//!Set the position of the entity
	/*!
	\param position The new position of the entity
	*/
	void setPosition(const CVector2i& position);

	//!Set the active flag of the entity
	/*!
	\param active True to activate the entity. False to deactivate the entity
	*/
	void setActive(bool active);

	//!Get the active flag.
	/*!
	\return False if the entity is not activate. True if the entity is activated.
	*/
	bool getActive(void)const;

	//!Set the side of the entity
	/*!
	\param side The side of the entity
	*/
	void setSide(eSide side);

	//!Get the side of the entity
	/*!
	\return The side of the entity.
	*/
	eSide getSide(void)const;

	//!Get the hp of the entity
	/*!
	\return The health point of the player.
	*/
	int getHealthPoint(void)const;

	//!Set the hp of the entity.
	/*!
	\param hp The new health point of the entity
	*/
	void setHealthPoint(int hp);

	//!Get the damage point of the entity
	/*!
	\return The damage point.
	*/
	int getDamagePoint(void)const;

	//!Set the damage point
	/*!
	\param dp The damage point to set.
	*/
	void setDamagePoint(int dp);

	//!Scroll the entity. Translate it.
	/*!
	\param scrollVector The translation vector to scroll the entity.
	*/
	virtual void scrollEntity(const CVector2i& scrollVector);

};

#endif

